package dao;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.cfg.CreateKeySecondPass;

import dao.utils.GenericHibernateDAO;
import domain.Articulos;
import domain.Empleados;

public class ArticulosDAOImpl extends GenericHibernateDAO implements ArticulosDAO {

	public ArticulosDAOImpl(Session s) {
		super(s);
	}
	
	public Articulos findByDni(String ID){		
		Articulos articulo= (Articulos) getSession().createQuery("From Articulos as art where art.idArticulo=?").setString(0, ID).uniqueResult();
		return articulo;
	}

	@Override
	public List<Articulos> findAll() {
		// TODO Auto-generated method stub
		Query q=getSession().createQuery("From Articulos");
		return q.list();
		
	}

	@Override
	public List<Articulos> findByArticuloVenta(boolean sale) {
		// TODO Auto-generated method stub
		Query q=getSession().createQuery("From Articulos as art where art.venta = "+sale+"");
		return q.list();
		
	}

	@Override
	public List<Articulos> findByArticuloInventariable(boolean inventoried) {
		// TODO Auto-generated method stub
		Query q=getSession().createQuery("From Articulos as art where art.inventariable = "+inventoried+"");
		return q.list();
		
	}

	@Override
	public List<Articulos> findByArticuloVentaInventariable(boolean sale,
			boolean inventoried) {
		// TODO Auto-generated method stub
		Query q=getSession().createQuery("From Articulos as art where art.venta = "+sale+" and art.inventariable = "+inventoried+"");
		return q.list();
		
	}

	@Override
	public Articulos findByID(String idart) {
		// TODO Auto-generated method stub
		Articulos Articulo= (Articulos) getSession().createQuery("From Articulos as art where art.idArticulo="+idart).uniqueResult();
		return Articulo;
	}
}
